package leetcode;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description: 给定链表头结点,判断是否是回文链表   123321
 * @date 2022/9/7 20:14
 */
public class Code27 {

    public boolean isPalindrome(ListNode head) {
        StringBuffer current = new StringBuffer();
        StringBuffer rever = new StringBuffer();
        while (head != null) {
            current.append(head.val);
            rever.append(head.val);
            head = head.next;
        }
        rever.reverse();
        return current.toString().equals(rever.toString());
    }



    public static void main(String[] args) {

    }



    public class ListNode {
         int val;
         ListNode next;
         ListNode() {}
         ListNode(int val) { this.val = val; }
         ListNode(int val, ListNode next) { this.val = val; this.next = next; }
     }
}
